package com.samuel.igoodman.dao;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

import org.apache.commons.dbutils.DbUtils;

public class Configurations {
	
	
	public final static Connection getConnection() {
		
		Connection conn = null;
		try {
			Properties dbProperties = new Properties();
			dbProperties.load(Configurations.class.getResourceAsStream("/db.properties"));
						
			String deriverClass = dbProperties.getProperty("jdbc.driverClass");
			String jdbcUrl =  dbProperties.getProperty("jdbc.jdbcUrl");
			String user =  dbProperties.getProperty("jdbc.user");
			String password = dbProperties.getProperty("jdbc.password");
			DbUtils.loadDriver(deriverClass);
			
			conn = DriverManager.getConnection(jdbcUrl, user, password);
			
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return conn;
	}

}
